//
//  IPhoneManager.swift
//  PeerTalkPlaygroundWithSPM
//
//  Created by Cosmetic Cygia on 2024/8/26.
//

import Foundation

class IPhoneManager {
    
    private var serialNumber: String = ""
    
    init() {
        self.serialNumber = getSerialNumber()
    }
    
    func messageHeartBeat(dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 0, "alive": 1])
    }
    
    func messageCameraControl(trigger: Bool, formula: String = "", volver: Bool = false, uuid: String = "",  dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 8, "trigger": trigger, "formula": formula, "volver": volver, "uuid": uuid])
    }
    
    func messageBlink(dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 20, "trigger": true])
    }
    
    func messageSetExpoTime(expoTime: Float, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 30, "expoTime": expoTime])
    }
    
    func messageSetIso(iso: Float, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 31, "iso": iso])
    }
    
    func messageSetEv(ev: Float, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 32, "ev": ev])
    }
    
    func messageSetZoom(zoom: Float, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 33, "zoom": zoom])
    }
    
    func messageSetFlash(trigger: Bool, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 34, "trigger": trigger])
    }
    
    func messageSetFocus(x: CGFloat, y: CGFloat, dst: String = "") -> String {
        return jsonDictToString(jsonDict: ["utc": getTimeStamp(), "src": self.serialNumber, "dst": dst, "action": 35, "x": x, "y": y])
    }
}
